# 创建第一个数值向量
vector1 <- c(12, 15, 18, 20, 22, 25, 28, 30, 32, 35)
# 创建一个因子
factor_groups <- factor(c("A", "A", "A", "B", "B", "B", "C", "C", "C", "C"))
# tapply计算不同组的均值
group_means <- tapply(vector1, factor_groups, mean)
print(group_means)
# 创建第2、3个数值向量
vector2 <- c(5, 8, 10, 12, 15, 18, 20, 22, 25, 28)
vector3 <- c(2, 5, 8, 10, 12, 15, 18, 20, 22, 25)
# 将所有向量合并成数据框
data_frame <- data.frame(
  Vector1 = vector1,
  Vector2 = vector2,
  Vector3 = vector3,
  Group = factor_groups
)
print(data_frame)
